<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/9/18
 * Time: 16:44
 */

namespace Admin\Controller;


use Admin\Service\UserService;
use Common\Base\BaseController;
use Common\Util\CommonUtil;

class LoginController extends BaseController
{
    private $userService = null;
    public function __construct()
    {
        parent::__construct();
        $this->userService = new UserService();
    }

    public function checkUserLogin($account,$password) {
        $authRet = json_decode(CommonUtil::auth(),true);
        if($authRet['status'] != 0) {
            $this->ajaxReturnWrap(null,7,$authRet['msg']);
        }
        
        $data['account'] = $account;
        $data['password'] = $password;

        try{
            $ret = $this->userService->checkUserLogin($data);
            if($ret) {
                $this->ajaxReturnWrap(null,0,'操作成功');
            } else {
                $this->ajaxReturnWrap(null,1,'用户名或者密码错误');
            }
        }
        catch (\LogicException $e) {
            $this->ajaxReturnWrap($e->getMessage());
        }
    }

}